/**
 */
package autoSAR.impl;

import autoSAR.AutoSARPackage;
import autoSAR.ClientServicePPort;
import autoSAR.ClientServiceRPort;
import autoSAR.Entity;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectResolvingEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Client Service PPort</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link autoSAR.impl.ClientServicePPortImpl#getDataFrom <em>Data From</em>}</li>
 *   <li>{@link autoSAR.impl.ClientServicePPortImpl#getPostTo <em>Post To</em>}</li>
 * </ul>
 *
 * @generated
 */
public class ClientServicePPortImpl extends ClientServicePortImpl implements ClientServicePPort {
	/**
	 * The cached value of the '{@link #getDataFrom() <em>Data From</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDataFrom()
	 * @generated
	 * @ordered
	 */
	protected EList<Entity> dataFrom;

	/**
	 * The cached value of the '{@link #getPostTo() <em>Post To</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPostTo()
	 * @generated
	 * @ordered
	 */
	protected ClientServiceRPort postTo;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ClientServicePPortImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return AutoSARPackage.Literals.CLIENT_SERVICE_PPORT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Entity> getDataFrom() {
		if (dataFrom == null) {
			dataFrom = new EObjectResolvingEList<Entity>(Entity.class, this,
					AutoSARPackage.CLIENT_SERVICE_PPORT__DATA_FROM);
		}
		return dataFrom;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ClientServiceRPort getPostTo() {
		if (postTo != null && postTo.eIsProxy()) {
			InternalEObject oldPostTo = (InternalEObject) postTo;
			postTo = (ClientServiceRPort) eResolveProxy(oldPostTo);
			if (postTo != oldPostTo) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE,
							AutoSARPackage.CLIENT_SERVICE_PPORT__POST_TO, oldPostTo, postTo));
			}
		}
		return postTo;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ClientServiceRPort basicGetPostTo() {
		return postTo;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetPostTo(ClientServiceRPort newPostTo, NotificationChain msgs) {
		ClientServiceRPort oldPostTo = postTo;
		postTo = newPostTo;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET,
					AutoSARPackage.CLIENT_SERVICE_PPORT__POST_TO, oldPostTo, newPostTo);
			if (msgs == null)
				msgs = notification;
			else
				msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPostTo(ClientServiceRPort newPostTo) {
		if (newPostTo != postTo) {
			NotificationChain msgs = null;
			if (postTo != null)
				msgs = ((InternalEObject) postTo).eInverseRemove(this, AutoSARPackage.CLIENT_SERVICE_RPORT__RECIVE_FROM,
						ClientServiceRPort.class, msgs);
			if (newPostTo != null)
				msgs = ((InternalEObject) newPostTo).eInverseAdd(this, AutoSARPackage.CLIENT_SERVICE_RPORT__RECIVE_FROM,
						ClientServiceRPort.class, msgs);
			msgs = basicSetPostTo(newPostTo, msgs);
			if (msgs != null)
				msgs.dispatch();
		} else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, AutoSARPackage.CLIENT_SERVICE_PPORT__POST_TO,
					newPostTo, newPostTo));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
		case AutoSARPackage.CLIENT_SERVICE_PPORT__POST_TO:
			if (postTo != null)
				msgs = ((InternalEObject) postTo).eInverseRemove(this, AutoSARPackage.CLIENT_SERVICE_RPORT__RECIVE_FROM,
						ClientServiceRPort.class, msgs);
			return basicSetPostTo((ClientServiceRPort) otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
		case AutoSARPackage.CLIENT_SERVICE_PPORT__POST_TO:
			return basicSetPostTo(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
		case AutoSARPackage.CLIENT_SERVICE_PPORT__DATA_FROM:
			return getDataFrom();
		case AutoSARPackage.CLIENT_SERVICE_PPORT__POST_TO:
			if (resolve)
				return getPostTo();
			return basicGetPostTo();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
		case AutoSARPackage.CLIENT_SERVICE_PPORT__DATA_FROM:
			getDataFrom().clear();
			getDataFrom().addAll((Collection<? extends Entity>) newValue);
			return;
		case AutoSARPackage.CLIENT_SERVICE_PPORT__POST_TO:
			setPostTo((ClientServiceRPort) newValue);
			return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
		case AutoSARPackage.CLIENT_SERVICE_PPORT__DATA_FROM:
			getDataFrom().clear();
			return;
		case AutoSARPackage.CLIENT_SERVICE_PPORT__POST_TO:
			setPostTo((ClientServiceRPort) null);
			return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
		case AutoSARPackage.CLIENT_SERVICE_PPORT__DATA_FROM:
			return dataFrom != null && !dataFrom.isEmpty();
		case AutoSARPackage.CLIENT_SERVICE_PPORT__POST_TO:
			return postTo != null;
		}
		return super.eIsSet(featureID);
	}

} //ClientServicePPortImpl
